class GameView {
    constructor(width, height) {
        this.width = width;
        this.height = height;

        //初始化数据
        this.initData();
        //初始化游戏界面
        this.initMap();
        //初始化灰太狼
        this.initWolf();
        //打击狼的分数点击事件
        this.wolfClick();
        this.Time();
        

    }
    initData() {
        this.grade = 0;
    }
    Time() {
        this.time = new GT();
        this.time.RState = this.setViewState.bind(this);
    }
    setViewState() {
        this.setGameState();
    }
    initMap() {
        this.gamemap = new GameMap(this.width, this.height);
    }
    initWolf() {
        this.wolf = new Wolf();
    }

    //狼的打击加分
    wolfClick() {
        this.wolf.onclick = this.Grade.bind(this);
    }
    Grade(Type) {
        if (Type == 0) {
            this.grade += 10;
        } else {
            this.grade -= 10;
        }
    }
   
    run(paint) {
        this.onDraw(paint);
    }
    onDraw(paint) {
        //绘制游戏界面
        this.gamemap.run(paint);
        this.wolf.run(paint);
        paint.fillText(this.grade, 100, 50);
        this.time.run(paint);
    }

    onmousedown(x, y) {
        this.wolf.onmousedown(x, y);
        

    }
}